home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Adobe Graphics & Publishing SDK 1996 December
/
Adobe Graphics & Publishing SDK 1996 December.iso
/
mac
/
Illustrator 6.0 SDK r1 Mac
/
AI Plugin Interface
/
AIFixedMath.h
< prev
next >
Wrap
Text File
|
1995-12-21
|
8KB
|
245 lines
/**
AIFixedMath.h
Copyright (c) 1995 Adobe Systems Incorporated.
All Rights Reserved
Adobe Illustrator 6.0 Fixed Point Math Suite.
**/
#ifndef __AIFixedMath__
#define __AIFixedMath__
/*******************************************************************************
**
** Imports
**
**/
#include "AITypes.h"
#if Macintosh
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=mac68k
#endif
#if PRAGMA_IMPORT_SUPPORTED
#pragma import on
#endif
#endif
/*******************************************************************************
**
** Constants
**
**/
#define kAIFixedMathSuite "AI Fixed Math Suite"
#define kAIFixedMathVersion 2
// common Fixed constants
#define kFixedMin ((Fixed) 0x80000000L)
#define kFixedMax ((Fixed) 0x7FFFFFFFL)
#define kFixedUnknown ((Fixed) 0x80000000L)
#ifndef kFixedOne
#define kFixedOne ((Fixed) 0x00010000L)
#endif
#ifndef kFixedZero
#define kFixedZero ((Fixed) 0x00000000L)
#endif
#define kFixedHundredth ((Fixed) 0x0000028FL)
#define kFixedSixteenth ((Fixed) 0x00001000L)
#define kFixedTenth ((Fixed) 0x00001999L)
#define kFixedEighth ((Fixed) 0x00002000L)
#ifndef kFixedQuarter
#define kFixedQuarter ((Fixed) 0x00004000L)
#endif
#ifndef kFixedHalf
#define kFixedHalf ((Fixed) 0x00008000L)
#endif
#define kFixedSevenEighths ((Fixed) 0x0000E000L)
#define kFixedOne1 ((Fixed) 0x0000FFFFL)
#define kFixedOneThird ((Fixed) 0x00005555L)
#define kFixedFourThirds ((Fixed) 0x00015555L)
#define kFixedThreeHalves ((Fixed) 0x00018000L)
#define kFixedPi4 ((Fixed) 0x0000C910L)
#define kFixedPi2 ((Fixed) 0x00019220L)
#define kFixedPi ((Fixed) 0x00032440L)
#define kFixedTwoPi ((Fixed) 0x00064880L)
#define kFixedGolden ((Fixed) 0x00019E37L)
// common Fract constants
#define kFractZero ((Fract) 0x00000000L)
#define kFractFixedRound ((Fract) 0x00002000L)
#define kFractPi180 ((Fract) 0x011DF4A0L)
#define kFractQuarter ((Fract) 0x10000000L)
#define kFractHalf ((Fract) 0x20000000L)
#define kFractOne ((Fract) 0x40000000L)
#define kFractFourThirds ((Fract) 0x55555555L)
#define kFractSqrtTwo ((Fract) 0x5A82799AL)
#define kFractUnknown ((Fract) 0x80000000L)
/*******************************************************************************
**
** Types
**
**/
typedef float Float; // 4 byte IEEE
#if __BUILD_PLUGIN__
typedef unsigned long UFract;
typedef struct {
Fixed h, v;
} FixedPoint;
typedef struct {
Fixed left, top, right, bottom;
} FixedRect;
typedef struct {
Fixed a, b, c, d, tx, ty;
} FixedMatrix;
#endif
/*******************************************************************************
**
** Macros
**
**/
#if __BUILD_PLUGIN__
// type conversion macros
#define _FixedToFract(a) ((Fract)(a) << 14)
#define _FractRoundToFixed(a) ((Fixed) (((a) + kFractFixedRound) >> 14))
#define _FractTruncToFixed(a) ((Fixed) ((a) >> 14))
#define _ShortToFixed(a) ((Fixed)(a) << 16)
#define _FixedRoundToShort(a) ((short) (((a) + kFixedHalf) >> 16))
#define _FixedTruncToShort(a) ((short) ((a) >> 16))
#define _FloatToFixed(a) ((Fixed)((a) * 65536.0)) // useful for constants; eg, _FloatToFixed(1.5) generates 0x00018000
// other macros
#define _FixedFloor(a) ((Fixed) ((a) & 0xFFFF0000L))
#define _FixedCeiling(a) _FixedFloor((a) + kFixedOne1)
#define _FixedRound(a) _FixedFloor((a) + kFixedHalf)
#define _FixedFraction(a) ((a) & 0x0000FFFFL)
#define _FixedAverage(a, b) (((a) + (b) + 1) >> 1)
#define _FixedHalf(a) (((a) + 1) >> 1)
#define _FixedOverflow(a) ((a) == kFixedMax || (a) == kFixedMin)
#endif
/*******************************************************************************
**
** Suite
**
**/
typedef struct {
MACPASCAL Fixed (*FixedAdd) ( Fixed a, Fixed b );
MACPASCAL Fixed (*FixedMul) ( Fixed a, Fixed b );
MACPASCAL Fract (*FractMul) ( Fract a, Fract b );
MACPASCAL Fixed (*FractFixedMul) ( Fract a, Fixed b );
MACPASCAL Fixed (*FixedDiv) ( Fixed a, Fixed b );
MACPASCAL Fract (*FractDiv) ( Fract a, Fract b );
MACPASCAL Fixed (*ShortRatio) ( short a, short b );
MACPASCAL Fract (*FixedRatio) ( Fixed a, Fixed b );
MACPASCAL Fixed (*FractRatio) ( Fract a, Fract b );
MACPASCAL Fixed (*FixedMulAdd) ( Fixed a, Fixed b, Fixed c, Fixed d );
MACPASCAL Fixed (*FixedMultiple) (Fixed a, Fixed multiple, Boolean ceiling );
MACPASCAL Fract (*FixedSin) ( Fixed a );
MACPASCAL Fract (*FixedCos) ( Fixed a );
MACPASCAL Fixed (*FixedATan) ( Fixed a, Fixed b );
MACPASCAL Fixed (*DegreeToRadian) ( Fixed degree );
MACPASCAL Fixed (*RadianToDegree) ( Fixed radian );
MACPASCAL UFract (*FractSqrt) ( UFract a );
MACPASCAL Fixed (*FixedLength) ( Fixed a, Fixed b );
MACPASCAL Fixed (*FixedInterpolate) ( Fixed a, Fixed b, Fixed t );
MACPASCAL Float (*FixedToFloat) ( Fixed a );
MACPASCAL Fixed (*FloatToFixed) ( Float a );
MACPASCAL Float (*FractToFloat) ( Fract a );
MACPASCAL Fract (*FloatToFract) ( Float a );
MACPASCAL void (*FixedPointAdd) ( FixedPoint *a, FixedPoint *b, FixedPoint *result );
MACPASCAL void (*FixedPointSubtract) ( FixedPoint *a, FixedPoint *b, FixedPoint *result );
MACPASCAL Boolean (*FixedPointEqual) ( FixedPoint *a, FixedPoint *b );
MACPASCAL Boolean (*FixedPointClose) ( FixedPoint *a, FixedPoint *b, Fixed tolerance );
MACPASCAL Fixed (*FixedPointAngle) ( FixedPoint *a, FixedPoint *b );
MACPASCAL Fixed (*FixedPointLength) ( FixedPoint *a, FixedPoint *b );
MACPASCAL void (*FixedPointLengthAngle) ( Fixed length, Fixed angle, FixedPoint *result );
MACPASCAL void (*FixedPointInterpolate) ( FixedPoint *a, FixedPoint *b, Fixed t, FixedPoint *result );
MACPASCAL void (*FixedRectSet) ( FixedRect *a, Fixed left, Fixed top, Fixed right, Fixed bottom );
MACPASCAL Boolean (*FixedRectEqual) ( FixedRect *a, FixedRect *b );
MACPASCAL Boolean (*FixedRectEmpty) ( FixedRect *a );
MACPASCAL void (*FixedRectInset) ( FixedRect *a, Fixed h, Fixed v );
MACPASCAL void (*FixedRectOffset) ( FixedRect *a, Fixed h, Fixed v );
MACPASCAL void (*FixedRectUnion) ( FixedRect *a, FixedRect *b, FixedRect *result );
MACPASCAL void (*FixedPointUnion) ( FixedPoint *a, FixedRect *b, FixedRect *result );
MACPASCAL Boolean (*FixedRectOverlap) ( FixedRect *a, FixedRect *b );
MACPASCAL Boolean (*FixedRectIntersect) ( FixedRect *a, FixedRect *b, FixedRect *result );
MACPASCAL Boolean (*FixedRectInFixedRect) ( FixedRect *a, FixedRect *b );
MACPASCAL Boolean (*FixedPointInFixedRect) ( FixedPoint *a, FixedRect *b );
MACPASCAL void (*FixedRectAlign) ( FixedRect *a, FixedRect *result );
MACPASCAL void (*FixedMatrixSet) ( FixedMatrix *m, Fixed a, Fixed b, Fixed c, Fixed d, Fixed tx, Fixed ty );
MACPASCAL void (*FixedMatrixSetIdentity) ( FixedMatrix *m );
MACPASCAL Boolean (*FixedMatrixEqual) ( FixedMatrix *m, FixedMatrix *n );
MACPASCAL Boolean (*FixedMatrixIdentity) ( FixedMatrix *m );
MACPASCAL Boolean (*FixedMatrixSingular) ( FixedMatrix *m );
MACPASCAL void (*FixedMatrixSetTranslate) ( FixedMatrix *m, Fixed tx, Fixed ty );
MACPASCAL void (*FixedMatrixSetScale) ( FixedMatrix *m, Fixed h, Fixed v );
MACPASCAL void (*FixedMatrixSetRotate) ( FixedMatrix *m, Fixed angle );
MACPASCAL void (*FixedMatrixConcatTranslate) ( FixedMatrix *m, Fixed tx, Fixed ty );
MACPASCAL void (*FixedMatrixConcatScale) ( FixedMatrix *m, Fixed h, Fixed v );
MACPASCAL void (*FixedMatrixConcatRotate) ( FixedMatrix *m, Fixed angle );
MACPASCAL void (*FixedMatrixConcat) (FixedMatrix *m, FixedMatrix *n, FixedMatrix *result );
MACPASCAL short (*FixedMatrixInvert) (FixedMatrix *m );
MACPASCAL void (*FixedMatrixXformPoint) ( FixedMatrix *m, FixedPoint *a, FixedPoint *result );
} AIFixedMathSuite;
#if Macintosh
#if PRAGMA_IMPORT_SUPPORTED
#pragma import off
#endif
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset
#endif
#ifdef __cplusplus
}
#endif
#endif
#endif